package org.wzl.springapplication.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.wzl.springapplication.service.UploadService;
import org.wzl.springapplication.utils.Result;

@RestController
@RequestMapping("/file")
public class FileController {

    @Autowired
    private UploadService uploadService;

    @PostMapping("/upload")
    public Result upload(MultipartFile file) {
        String url = "";
        try {
            url = uploadService.upload(file);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return Result.add_("path", url);
    }

}
